package J1_4;

import java.util.Scanner;

public class J104task2 {
    public static void main(String[] args) {
        double x1,y1,x2,y2,sun;
        Scanner scanner =new Scanner(System.in);
        System.out.print("输入第一个坐标的横坐标:");
        x1=scanner.nextDouble();
        System.out.print("输入第一个坐标的纵坐标:");
        y1=scanner.nextDouble();
        System.out.print("输入第二个坐标的横坐标:");
        x2=scanner.nextDouble();
        System.out.print("输入第二个坐标的纵坐标:");
        y2=scanner.nextDouble();
        sun=juli(x1,y1,x2,y2);
        System.out.println("两点之间的距离为:"+String.format("%.2f",sun));
    }
    private  static  double juli(double x1,double y1,double x2,double y2){
        double sun=0.0;
        double x,y;
        x=(x1-x2)*(x1-x2);
        y=(y1-y2)*(y1-y2);
        sun=x+y;
        sun=Math.sqrt(sun);
        if(sun<0)
            return  -sun;
        return sun;
    }
}
